Skip to content

Preserve cask choice zeroes#22401

Merged
MikeMcQuaid merged 1 commit into
mainfrom
fix-cask-choice-zeroes
May 23, 2026
Merged

Preserve cask choice zeroes#22401
MikeMcQuaid merged 1 commit into
mainfrom
fix-cask-choice-zeroes

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

Fixes #22400

  • Keep attributeSetting: 0 in internal API cask artifacts because installer choices need zero as a meaningful value.
  • Allow Utils.deep_compact_blank callers to opt out of dropping zeroes while preserving existing default behaviour.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR.

- Keep `attributeSetting: 0` in internal API cask artifacts
  because installer choices need zero as a meaningful value.
- Allow `Utils.deep_compact_blank` callers to opt out of dropping
  zeroes while preserving existing default behaviour.
Copilot AI review requested due to automatic review settings May 23, 2026 19:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes internal API cask artifact serialization so that installer choice settings with attributeSetting: 0 are preserved (since 0 is a meaningful value for macOS installer choices), by making Utils.deep_compact_blank optionally retain numeric zeroes.

Changes:

  • Add a compact_zero: keyword option to Utils.deep_compact_blank (defaulting to current behavior of compacting zeroes).
  • Preserve zero values when compacting/serializing raw_artifacts in Homebrew::API::CaskStruct#serialize.
  • Add a regression test ensuring attributeSetting: 0 survives serialization in cask artifacts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/utils.rb Adds compact_zero: option to allow callers to preserve numeric zeroes while deep-compacting.
Library/Homebrew/api/cask_struct.rb Ensures raw_artifacts serialization retains 0 values (notably attributeSetting: 0) while still compacting blanks elsewhere.
Library/Homebrew/test/api/cask_struct_spec.rb Adds coverage to prevent regression for zero-valued installer choice settings in serialized artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid MikeMcQuaid enabled auto-merge May 23, 2026 20:02
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 23, 2026
Copy link
Copy Markdown
Member

@Rylan12 Rylan12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MikeMcQuaid I wonder if not stripping out 0 values everywhere would be an okay choice. I know it's used for things like bottle rebuild and revision, but adding "revision": 0 to a whole bunch of formulae might not increase the compressed size very much... might be worth a try

Merged via the queue into main with commit dd41b40 May 23, 2026
41 checks passed
@MikeMcQuaid MikeMcQuaid deleted the fix-cask-choice-zeroes branch May 23, 2026 21:18
@MikeMcQuaid
Copy link
Copy Markdown
Member Author

@Rylan12 Yeh, if we encounter more bugs that's an option but would rather still omit for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Casks with choices: failing to install after commit 2d33360

4 participants